<div id="search">
<?php
	//construction de la requete
	$elements=array();
	$req="//videos/video";
	
	if(isset($_GET['s'])){
	
		$keywords=explode(" ",$_GET['s']);

		foreach($keywords as $key){
		
			$req="//videos/video[contains(./nom,'".$key."') or contains(./description,'".$key."') or contains(./difficulte,'".$key."')";
		
			//verification que le mot cle courant ne soit pas un theme
			$id_theme=requeteXPath("//themes/theme/@id[contains(../designation,'". $key ."')]");
			
			if(empty($id_theme)){
			
				$req.="]";
			
			}else{
				
				$themechoisi=$id_theme[0];
				$req.=" or contains(./@id_theme,'".$themechoisi['id']."')]";
			
			}//fin if/else
			
			$elements+=requeteXPath($req);
			
		}//fin foreach
	
	}else{
	
		$elements=requeteXPath($req);
	
	}//fin if/else
	
	//Affichage de la requete
	$limiteParPage=2;
	echo "<h1>Résultat de la recherche : </h1>";
	if(empty($elements)){
	
		echo "<p>Aucun élément trouvé</p>";
	
	}else{
	
		foreach($elements as $video){
	
			echo "<div class='miniature row-fluid'>";
				echo "<div class='span3 miniature_video'>";
					echo "<a href=\"video.php?id=" . $video['id'] . "\"><img src=\"./image/charte/miniature1.png\" alt=\"problème d'affichage\"/></a>";
				echo "</div>";
				echo "<div class='span6 description_video'>";
					echo "<p><span>Nom de la video : </span>";
					echo "<a href=\"video.php?id=" . $video['id'] . "\">". $video->nom ."</a></p>";
					echo "<p><span>Description : </span>";
					echo $video->description."</p>";
					echo "<div class='inline'>";
						echo "<p><span>Thème : </span>";
						echo nomtheme($video['id_theme'])."</p>";
						echo "<p><span>Temps : </span>";
						echo $video->duree."</p>";
						echo "<p><span>Difficulté : </span>";
						echo $video->difficulte."</p>";
					echo "</div>";
				echo "</div>";//fin description_video
			echo "</div>";
	
		}//fin foreach
	
	}//else
	
?>
</div>